#include "cJSON/cJSON.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    cJSON *root= cJSON_CreateObject();
    cJSON_AddStringToObject(root, "name", "zhangtao");
    cJSON_AddNumberToObject(root, "age", 18);
    char *cJSONStr=cJSON_PrintUnformatted(root);
    log_debug("%s",cJSONStr);
    cJSON *root1=cJSON_Parse(cJSONStr);
    if(root1==NULL){
        log_error("cJSON_Parse error");
        return -1;
    }
    cJSON *name=cJSON_GetObjectItem(root1,"name");
    cJSON *age=cJSON_GetObjectItem(root1,"age");
    if(name==NULL||age==NULL){
        log_error("cJSON_GetObjectItem error");
        return -1;
    }
    char *name1=name->valuestring;
    int age1=age->valueint;
    log_debug("name:%s,age:%d",name1,age1);
    return 0;
}
